<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue路由</title>
</head>
<body>
<div id="app">
    <router-view></router-view>
    <h1>{{msg}}</h1>
<!--    指定路由组件在哪里显示 router-view标签  作用:就是用来展示路由对应组件显示的位置-->
    <router-view></router-view>

    <a href="#/users">用户管理</a>
    <a href="#/emps">员工管理</a>
</div>
</body>
</html>
<script src="../js/vue.js"></script>
<script src="../js/vue-router.js"></script>
<script src="../js/axios.min.js"></script>
<script>

    const users = {
        template: "<div><h3>用户管理</h3><table border='1'><tr><th>编号</th><th>姓名</th><th>年龄</th><th>生日</th><th>操作</th></tr></table></div>"
    };
    const emps = {
        template: "<div><h3>员工管理</h3><table border='1'><tr><th>编号</th><th>姓名</th><th>年龄</th><th>生日</th><th>操作</th></tr></table></div>"
    };

    //创建路由对象并定义路由规则
    const router = new VueRouter({
        routes: [
            {path: '/users',component:users}, //path指定路径  component指定组件
            {path: '/emps',component:emps}
        ],

    });
    const app = new Vue({
        el: "#app",
        data: {
            msg: "路由的使用"
        },
        methods: {},
        computed: {},
        components: {
            users,
            emps,
        },
        router:router,
    })
</script>
